#coding=utf-8
from datetime import *
from dateutil.relativedelta import *

from stockdb.misc import *
con = sess.connection() 

results = []
a = date(2000,1,1)
end = date(2008, 8, 1)

da = relativedelta(months=+6)
while a < end:
    #print a.isoformat()
    sql = 'select count(*) from stock where ipo < "%s";'%a.isoformat()
    n = con.execute(sql).fetchone()[0]
    results.append([a.isoformat(),n])
    
    a = a + da
        
for i in results:
    print i[0], i[1]
    
